<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>
  <head>    
    <title>密码修改</title>
    <base href="<%=basePath%>">
	<link rel="stylesheet" type="text/css" href="/css/edittable.css"></link>  
	<link rel="stylesheet" type="text/css" href="/css/validate.css"></link>  
	<style>
		.td_input{
			width:210px;
		}
	 </style>
	<script type="text/javascript"  src="/js/jquery-1.8.0.js"></script>
	<script type="text/javascript">
		var result1 = false;
		var result2 = false;
		var result3 = false;
		$(function(){
			$("#oldPassword").blur(function(){
				var l=$("#oldPassword").val();
				$.ajax({
					url:"AdminServlet.do",
					type:"post",
					data:{oldPassword:l,flag:"checkoldPassword"},
					success:function(data){
						if(data==1){
							$("#oldPassword_msg").html("√");
							$("#oldPassword_msg").css("color","green");
							result1=true;
						}else{
							$("#oldPassword_msg").html("原密码输入不正确");
							$("#oldPassword_msg").css("color","red");
							result1=false;
						}
					}
				})
			})
			
			$("#password").blur(function(){
				var text = /^[a-zA-Z0-9]{6,20}$/;
				var a=$("#password").val();
				if(text.test(a)){
					$("#password_msg").html("√");
					$("#password_msg").css("color","green");
					result2=true;
				}else{
					$("#password_msg").html("输入错误，数字或英文,6-20位");
					$("#password_msg").css("color","red");
					result2=false;
				}
			})
			
			$("#pwdconfirm").blur(function(){
				var b=$("#password").val();
				var a=$("#pwdconfirm").val();
				if(b==a){
					$("#pwdconfirm_msg").html("√");
					$("#pwdconfirm_msg").css("color","green");
					result3=true;
				}else{
					$("#pwdconfirm_msg").html("输入错误，两次输入的密码不一致");
					$("#pwdconfirm_msg").css("color","red");
					result3=false;
				}
			})
		})
		
		function validateInput(){
			result=result1&&result2&&result3
			if(result){
				var l=confirm("确认修改吗");
				if(l){
					return true;
				}else{
					return false;
				}
			}else{
				alert("请按要求填写信息");
				return false;
			}
		}
	</script>
  </head>
  
  <body>
     <div class ="div_title">
		 <div class="div_titlename"><span>用户密码修改</span></div>
	 </div>
				 
	 <form action="AdminServlet.do?flag=updatepassword" method="post"  onsubmit="return validateInput()">
	 	<input type="hidden" name="flag" value="updatePassword" />
		 <table class="edit_table" >
		 		<tr>
		 			 	<td class="td_info">用户账号:</td>	
		 			 	<td class="td_input"> 
		 			 		<input  type="text" readonly="readonly" class="txtbox" name="adminName"  value='${session_admin.adminName}' />
		 			 	</td>   
		 			 	<td>
		 			 	</td> 
		 		</tr>
		 			<tr>
		 				<td class="td_info">原来的密码:</td>	
		 				<td>
		 					<input type="password"  class="txtbox"   id="oldPassword" name="oldPassword"/>
		 				</td> 
		 				<td><label  class="validate_info" id="oldPassword_msg" >请输入原来的密码</label></td>	
		 		  </tr>
		 		  <tr>
		 				<td class="td_info">新密码:</td>	
		 				<td>
		 					<input type="password"  class="txtbox"   id="password" name="password"/>
		 				</td> 
		 				<td><label  class="validate_info" id="password_msg" >数字或英文,6-20位</label></td>	
		 		  </tr>
		 		  
		 			<tr>
		 				<td class="td_info">重复密码:</td>	
		 				<td><input type="password" class="txtbox" id="pwdconfirm" /> 
		 				</td>
		 				<td><label  class="validate_info"  id="pwdconfirm_msg">请重复输入密码</label></td>	
		 		</tr>

		 		<tr>
		 			<td class="td_info"> </td>	
		 			<td> 
		 			<input class="form_btn" type="submit" value="提交"/> 
		 			<input type="reset"  class="form_btn" value="重置"/></td>	
		 			<td>
		 				<label id="result_msg" class="result_msg">${msg}</label>
		 			</td>	
		 		</tr>
		</table>
	
     </form>
  </body>
</html>
